package com.bfsuol.yihang.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/yihang/sentinel")
public class SentinelController {


    @GetMapping("/index")
    @SentinelResource(value = "sentinel-index",blockHandler = "sentinelIndexBlockHandler")
    public String index() {
        return "sentinel/index";
    }

    public String sentinelIndexBlockHandler(BlockException ex) {
        return "被流控了"+ex.getMessage();
    }
}
